// 使用 AutoCloseable 实现简单的计数器管理
class Counter implements AutoCloseable{
    private int count = 0;
    
    public void increment() { 
        ++count; 
        System.out.println("Incremented to " + count);
    }

    @Override
    public void close() throws Exception {
        if(count > 0){
            throw new RuntimeException("Resource was used");
        }
    }
}

// 使用 Closeable 来定义一个基于文件读写的类
import java.io.*;
class FileReaderExample implements Closeable {

    BufferedReader br;

    public FileReaderExample(String fileName) throws FileNotFoundException {
        this.br = new BufferedReader(new FileReader(fileName));
    }

    @Override
    public void close() throws IOException {
        br.close();
    }
}